//Source file: D:\\aaa\\com\\ce\\pms\\renovation\\model\\RenovateChargeItemDO.java

package com.ce.pms.renovation.model;

import java.math.BigDecimal;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.common.util.BigDecimalUtil;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.system.renovation.model.RenovateChargeItemConfigDO;

/**
 * 装修许可证收费项目
 *
 * @author yandawei
 * @CreateDate:2008-12-17
 */
@Entity
@DiscriminatorValue("001")
public class RenovateChargeItemDO extends AbstractChargeItemDO {

	/**
	 *
	 */
	private static final long serialVersionUID = -1696700488337992295L;

	/**
	 * 装修申办
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="HOST_ID")
	private RenovateRequisitionDO renovateRequisition;

	/**
	 * 装修收费项目配置对象
	 */
	@ManyToOne
	@JoinColumn(name = "ITEM_CONFIG_ID")
	private RenovateChargeItemConfigDO itemConfig;

	/**
	 * @roseuid 4940770D038A
	 */
	public RenovateChargeItemDO() {

	}

	public RenovateChargeItemDO(Long keyword) {
		super(keyword);
	}

	public RenovateChargeItemConfigDO getItemConfig() {
		return itemConfig;
	}

	public void setItemConfig(RenovateChargeItemConfigDO itemConfig) {
		this.itemConfig = itemConfig;
	}

	public RenovateRequisitionDO getRenovateRequisition() {
		return renovateRequisition;
	}

	public void setRenovateRequisition(RenovateRequisitionDO renovateRequisition) {
		this.renovateRequisition = renovateRequisition;
	}

	@Override
	public BigDecimal calculateFee() {
		BigDecimal result=null;
		if(SysrefcodeDO.RM_RENOVATE_CHARGE_MODE_FIXATION.equals(itemConfig.getChargeMode())){
			result = itemConfig.getPrice();
		}else if(SysrefcodeDO.RM_RENOVATE_CHARGE_MODE_SIZE.equals(itemConfig.getChargeMode())){
			result = itemConfig.getPrice().multiply(renovateRequisition.getArea());
		}else{
			throw new BusinessException("收费项目配置计费模式出错",BusinessException.ERROR);
		}
		return BigDecimalUtil.warpResult(result);
	}
}
